package com.glorysoft.lipuxinpda.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.glorysoft.lipuxinpda.R;
import com.glorysoft.lipuxinpda.entity.AlarmInfoEntity;

import java.util.List;

public class AlarmInfoRecyclerViewAdapter extends RecyclerView.Adapter<AlarmInfoRecyclerViewAdapter.ViewHolder>{

    private List<AlarmInfoEntity> mList;

    public void setmList(List<AlarmInfoEntity> mList) {
        this.mList = mList;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_textview, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        AlarmInfoEntity alarmInfoEntity = mList.get(position);
        holder.tv_key.setText(alarmInfoEntity.getALARM_MESSAGE());
        holder.tv_value.setText(alarmInfoEntity.getALARM_COUNT());
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder{
        private TextView tv_key;//报警消息
        private TextView tv_value;//报警数量

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tv_key = itemView.findViewById(R.id.tv_key);
            tv_value = itemView.findViewById(R.id.tv_value);
        }
    }
}
